<?php

namespace app\v1\controller;

use think\Controller;
use think\Request;
use think\Validate;

/**
 * Class Leave
 * @package app\v1\controller
 * 请假模块控制器
 */
class Leave extends Authorization
{
    //提交请假
    public function commitLeave(){
        $startDate=input('start_date',null);
        $endDate=input('end_date',null);
        $validate=new Validate([
            'start_date'=>'require|date',
            'end_date'=>'require|date'
        ]);
        $validate->message([
            'start_date.require'=>'开始日期不能为空',
            'start_date.date'=>'开始日期格式不正确',
            'end_date.require'=>'结束日期不能为空',
            'end_date.date'=>'结束日期格式不正确'
        ]);
        $data=$this->request->post();
        if(!$validate->check($data)){
            renderInfo(400001,$validate->getError());
        }
        $leave=model('v1/Leave');
        $leave->commitLeave($startDate,$endDate);
    }
    //获取请假列表
    public function getLeaveList(){
        $leave=model('v1/Leave');
        $leave->getLeaveList();
    }
    //取消请假

    public function cancelLeave(){
        $leaveIds=input('leaveIds',null);
        $leave=model('v1/Leave');
        $leave->cancelLeave($leaveIds);
    }
}
